FROM {{ namespace }}/{{ infra_image_prefix }}prometheus-base:{{ tag }}
{% block labels %}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% endblock %}

{% block prometheus_cadvisor_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{% block prometheus_cadvisor_repository_version %}
ENV prometheus_cadvisor_version=0.38.7
ENV prometheus_cadvisor_sha256sum=fdb86c256df682cfec2abd57a4405c919ed26f1e27ebfabf487f6c516bc7f6c7
{% endblock %}

{% if base_arch in ['x86_64'] %}

{% block prometheus_cadvisor_install %}
RUN curl -o /tmp/cadvisor https://github.com/google/cadvisor/releases/download/v${prometheus_cadvisor_version}/cadvisor \
    && echo "${prometheus_cadvisor_sha256sum} /tmp/cadvisor" | sha256sum -c \
    && mv /tmp/cadvisor /opt \
    && chmod 0755 /opt/cadvisor
{% endblock %}

{% else %}

   {% if base_distro in ['debian'] %}

        {% set cadvisor_packages = [
             'libjs-bootstrap',
             'libjs-jquery',
             'cadvisor'
        ] %}

{{ macros.install_packages(cadvisor_packages | customizable("packages")) }}
RUN ln -s /usr/bin/cadvisor /opt/cadvisor
   {% endif %}

{% endif %}

{% block prometheus_cadvisor_footer %}{% endblock %}
{% block footer %}{% endblock %}
